---
title: Optimize
description: Tools - Optimize | Transloco Angular i18n
---

This library will do the following things:

- AOT translation file flatting
- Remove translators comments
- Minify the JSON file

### Installation

```bash
npm install @ngneat/transloco-optimize --save-dev
```

### Usage

Add to your `package.json` the following script:

```json title="package.json"
"scripts": {
  "transloco:optimize": "transloco-optimize dist/appName/assets/i18n",
  "build:prod": "ng build --prod && npm run transloco:optimize",
}
```

Then, add the following config [option](../config-options#flattenaot) to the application Transloco `config` object:

```ts
import { environment } from '../environments/environment';

{
  flatten: {
    aot: environment.production,
  },
};
```

You can also use it as a function:
```ts
import translocoOptimize from '@ngneat/transloco-optimize';
import { task } from 'gulp';

// e.g: `${__dirname}/dist/${appName}/assets/i18n`;
const pathToLocales = ...

task('transloco:optimize', function(cb) {
  translocoOptimize({ dist: pathToLocales }).then(cb);
});
```
